<?php

class FormTreeView extends FormControl {

	public static $property = array(
		'wbtype',
		'name',
		'caption',
		'x',
		'y',
		'width',
		'height',
		'disabled',
		'lines',
		'visible'
	);	
	
	public function __construct() { 
		parent::__construct(array(
			'wbtype' => 'TreeView',
			'x' => 0,
			'y' => 0,
			'width' => 100,
			'height' => 100
		));
	}

	/**
	 * 컨트롤 그리기 
	 * 
	 * @param WBGraphics $graphics
	 */
	public function displayControl(WBGraphics $g) {

		$xstart = $this->getOption('x');
		$ystart = $this->getOption('y');
		$width = $this->getOption('width');
		$height = $this->getOption('height');		
		$caption = $this->getOption('caption');		
		$xend = $xstart + $width;
		$yend = $ystart + $height;	
		
		if(ProjectManager::$checkWireFrame->isChecked()) { 
			$pushbutton = new FormPushButton();
			$pushbutton['caption'] = $caption;
			$pushbutton['x'] = $xstart;
			$pushbutton['y'] = $ystart;
			$pushbutton['width'] = $width;
			$pushbutton['height'] = $height;
			$pushbutton['disabled'] = $this['disabled'];
			$pushbutton->displayControl($g);		
		} else { 
			$editbox = new FormEditBox();
			$editbox['x'] = $xstart;		
			$editbox['y'] = $ystart;		
			$editbox['width'] = $width;		
			$editbox['height'] = $height;		
			$editbox['caption'] = "";
			$editbox['disabled'] = $this['disabled'];
			$editbox->displayControl($g);			
		}
		
		$scrollbar = new FormScrollBar();
		$scrollbar['x'] = $xstart + $width - 19;		
		$scrollbar['y'] = $ystart + 1;		
		$scrollbar['width'] = 18;		
		$scrollbar['height'] = $height - 2;		
		$scrollbar['caption'] = $caption;
		$scrollbar['disabled'] = $this['disabled'];
		$scrollbar->displayControl($g);				
		
		// Draw image
		if (!ProjectManager::$checkWireFrame->isChecked()) { 
			$image = ($this['lines'])? self::$draw_treeview_lines : self::$draw_treeview;
					
			$g->image($image, $xstart + 2, $ystart + 2, $width - 20, $height - 4);
		}
	}
	
	public function getProperty() { 
		return self::$property;
	}	
}


?>